# -*- coding: utf-8 -*-
import collections
import numpy as np

# feature = np.load("../data/skynet_feature.npz")
# weight = np.load("../data/skynet_weight.npz")

# feature = np.load("../data/skynet_feature_int32_HWC.npz")
feature = np.load("../data/feature_int32_HWC_big.npz")
weight = np.load("../data/skynet_weight_int32_KKC_OCIC.npz")

print("Feature")
for key in feature.files:
    arr = feature[key]
    print(key, end=" ")
    print(arr.dtype, arr.shape, arr.min(), arr.max())
print()

print("Weight")
for key in weight.files:
    arr = weight[key]
    print(key, end=" ")
    print(arr.dtype, arr.shape, arr.min(), arr.max())

#%%
# feat_t = collections.OrderedDict()
# for key in feature.files:
#     arr = feature[key].astype(np.int32)
#     arr.resize(arr.shape[1:])
#     feat_t[key] = arr.transpose((1, 2, 0))
# np.savez("../data/skynet_feature_int32_HWC.npz", **feat_t)

# weight_t = collections.OrderedDict()
# for key in weight.files:
#     arr = weight[key].astype(np.int32)
#     shape = arr.shape
#     if len(shape) == 4:
#         if shape[1] == 3 and shape[2] == 3 and shape[3] == 1:
#             arr = arr.reshape(shape[:3])
#             arr = arr.transpose((1, 2, 0))
#         elif shape[1] == 1 and shape[2] == 1:
#             arr = arr.reshape((shape[0], shape[3]))
#         else:
#             assert False
#     elif len(shape) != 1:
#         assert False
#     weight_t[key] = arr
# np.savez("../data/skynet_weight_int32_KKC_OCIC.npz", **weight_t)
